import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaTop, WeaTab, WeaRightMenu, WeaLocaleProvider, WeaAlertPage } from 'ecCom';
import { observable, action, toJS } from 'mobx';
import { Icon } from 'antd';

const getLabel = WeaLocaleProvider.getLabel;

@inject('sendSmsStore')
@observer
class SendResult extends React.Component {
	constructor(props) {
    	super(props);
	    this.state = {
            isCus: props.isCus,
	    };
	  }

	componentDidMount() {
	 }
    render() {
        const { regularChk } = this.props.sendSmsStore;
        if (this.state.isCus) {
            return (
                <div className="sms-result" id="result">
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@n27aks`} datas={this.getRightMenu()} onClick={this.onRightMenuClick.bind(this)}>
                        {this.props.result == true ?
                            <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@1uwu52`} iconSize="70" icon="icon-coms-Approval result-ico-success" style={{ paddingTop: '20%' }}>
                                <div>
                                    <span className="result-font">{regularChk == 1 ? getLabel(521764, '已保存短信至"定时发送短信列表"') : getLabel(384209, '短信发送成功')}</span>
                                </div>
                            </WeaAlertPage>
                            :
                            <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@mdxkaj`} iconSize="70" icon="icon-coms-Clear result-ico-error" style={{ color: '#FF5500', paddingTop: '20%' }}>
                                <div>
                                    <span className="result-font">{getLabel(24544, '短信发送失败')}</span>
                                </div>
                            </WeaAlertPage>
                        }
                    </WeaRightMenu>
                </div>
                );
        }
            return (
                <div className="sms-result" id="result">
                    <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@t1kn7s`}
                      title={getLabel(16635, '发送短信')}
                      loading={false}
                      icon={<i className="icon-coms-message" />}
                      iconBgcolor="#0079de"
                      buttons={[]}
                    >
                        <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@t2nqut`} datas={this.getRightMenu()} onClick={this.onRightMenuClick.bind(this)}>
                            {this.props.result == true ?
                            <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@y4qg9k`} iconSize="70" icon="icon-coms-Approval result-ico-success" style={{ paddingTop: '20%' }}>
                                <div>
                                    <span className="result-font">{regularChk == 1 ? getLabel(521764, '已保存短信至"定时发送短信列表"') : getLabel(384209, '短信发送成功')}</span>
                                </div>
                            </WeaAlertPage>
                            :
                            <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@3ebi0x`} iconSize="70" icon="icon-coms-Clear result-ico-error" style={{ color: '#FF5500', paddingTop: '20%' }}>
                                <div>
                                    <span className="result-font">{getLabel(24544, '短信发送失败')}</span>
                                </div>
                            </WeaAlertPage>
                            }
                        </WeaRightMenu>
                    </WeaTop>
                </div>
            );
    }

 	getRightMenu() {
        let btns = [];
        btns.push({
            icon: <i className="icon-coms-Revoke" />,
            content: getLabel(1290, '返回'),
        });
        return btns;
    }
    // 右键菜单事件绑定
    onRightMenuClick(key) {
        if (key == '0') {
            const { sendSmsStore } = this.props;
            sendSmsStore.clearStatus();
	        this.props.changeType('init');
        }
    }
}

export default SendResult;
